<?php
	class BoatView{
		private $m_memberId = "memberid";
		private $m_boatType = "boattype";
		private $m_boatLength = "boatlength";
		private $m_registerSubmit = "regboat";
		private $m_updateBoat = "updateBoat";
		
		public function RenderRegisterBoat(){
			$CreateForm = "<form name='frmRegBoat' id='frmRegBoat' method='get'>	    		
			<p>First Name:</p>			
			<input type='text' name='$this->m_memberId' id='registerMemberId/><br/>
			<p>Last Name:</p>			
			<input type='text' name='$this->m_boatType' id='registerBoatType /><br/>			
			<p>Social number:</p>							
			<input type='text' name='$this->m_boatLength' id='registerBoatLength' /><br/> 	
						
			<input type='submit' value='Create' name='$this->m_registerSubmit' id='Create' />	
					  			
		</form>";
		}
		public function GetMemberId(){
			if(isset($_GET[$this->m_memberId])){
				return $_GET[$this->m_memberId];
			}
			return NULL;
		}
		public function GetBoatType(){
			if(isset($_GET[$this->m_boatType])){
				return $_GET[$this->m_boatType];
			}
			return NULL;
			
		}
		public function GetBoatLength(){
			if(isset($_GET[$this->m_boatLength])){
				return $_GET[$this->m_boatLength];
			}
			return NULL;
			
		}
		public function TriedToRegister(){
			if(isset($_GET[$this->m_registerSubmit])){
				return TRUE;
			}
			return FALSE;
		}
		
		public function RenderBoatList($id, $boatArray)
		{
			$ret = null;
			foreach ($boatArray->Get() as $boat)
			{
				if($boat->GetMemberID() == $id)
				{
					$ret .= "<p>BoatID: " . $boat->GetID() . "</br>";
					$ret .= "Boattype: " . $boat->GetType() . "</br>";
					$ret .= "Boatlenght: " . $boat->GetLenght() . "</p>";
				}	
				
			}
			
			return $ret;
		}
			
		public function RenderSpecificBoat($memberId, $boatArray) 
		{
			
			$ret = null;
			foreach ($boatArray->Get() as $boat)
			{
				if($boat->GetMemberID() == $memberId)
				{				
					$ret .= 	
					"<form name='editDeleteBoat' method='post'>	    		
					
					<p>Boat type:</p>			
					<input type='text' name='$this->m_boatType' value='" . $boat->GetType() . "'/>
					
					<p>Boat Lenght:</p>			
					<input type='text' name='$this->m_boatLength' value='" . $boat->GetLenght() . "' />			
					
					<input type='submit' value='Update' name='$this->m_updateBoat' />
					
					</form>";	
				}
			}
	  		return $ret;
		}
			
	}
?>

















